﻿using System.Windows;

namespace Genetic
{
    /// <summary>
    /// Interaktionslogik für "App.xaml"
    /// </summary>
    public partial class App : Application
    {
        public App()
        {
#if DEBUG
            System.Diagnostics.Stopwatch st = new System.Diagnostics.Stopwatch();
            st.Start();
#endif
            //load settings
            Helper.Settings.Load();
            Helper.Template.Load();
#if DEBUG
            st.Stop();
            System.Diagnostics.Debug.WriteLine("loading settings.xml and template.xml: " + st.ElapsedMilliseconds + "ms");
#endif

            //if (Settings.Data.Data.General.AutoUpdate.Update.Downloaded)
            //{
            //    //install update
            //    AutoUpdate.AutoUpdate autoUpdate = new AutoUpdate.AutoUpdate("", "", "", null);
            //    if (autoUpdate.Install())
            //        return;
            //}

            ////remove installed update
            //if (Settings.Data.Data.General.AutoUpdate.Update.Installed)
            //    AutoUpdate.AutoUpdate.RemoveUpdate();

            ////download update
            //if (Settings.Data.Data.General.AutoUpdate.Enabled && Settings.Data.Data.General.AutoUpdate.UpdateFile != null && Settings.Data.Data.General.AutoUpdate.LastCheck.Date.AddDays(Settings.Data.Data.General.AutoUpdate.CheckInterval) <= DateTime.Now.Date)
            //    Update.BackgroundCheck();
        }

        void Application_Exit(object sender, ExitEventArgs e)
        {
            Helper.Settings.Save();
        }
    }
}
